{% extends 'base-system.html' %}

{% block onload %}
onload='checkIfSuccess();'
{% endblock onload %}


{% block content %}
<script language="javascript">
	var success = false;
	/**
	 * Display error if failed.
	 **/
	function checkIfSuccess(){
		// hide my update progress
			dojo.query('#updateprogress').addClass('hidden');
		// if no success, show error
			if(!success) dojo.query('#updateerror').removeClass('hidden');
		return true;
	}
	
	/**
	 * Update my counters
	 * @param integer
	 **/
	function updateCounters(changes, todos){
		// It was a success so show!
			dojo.query('#updatesuccess').removeClass('hidden');
		// Update counters with values
			dojo.byId('updatenumofchanges').innerHTML = changes;
			dojo.byId('updatenumoftodos').innerHTML = todos;
		// Show log if changes are more than zero
			if(changes > 0) showLog();
		return true;
	}
	/**
	 * Display log
	 **/
	function showLog(){
			dojo.query('#updateframe').removeClass('hidden');
		return true;
	}


</script>

<div id='updateprogress' class='updatetitle updateprogress'><img src='{{baseurl}}system/img/icon/ajax-loader.gif'> update "{{ updatename }}" is running... </div>
<div id='updatesuccess' class='updatetitle updatesuccess hidden'><img src='{{baseurl}}system/img/icon/ajax-okay.png'> update "{{ updatename }}" was successful!</div>
<div id='updateerror' class='updatetitle updateerror hidden'><img src='{{baseurl}}system/img/icon/ajax-error.png'> update "{{ updatename }}" had errors! <a onclick='showLog();'>see log</a>.</div>
	<br>
	<div class='updatelog'>
		<big>update log (<div class='inline' id='updatenumofchanges'>--</div> automatic changes done, <div class='inline' id='updatenumoftodos'>--</div> manual changes waiting) | <a onclick='showLog();'>show</a> |</big><br>
		<iframe class='hidden' src="{{baseurl}}update/{{updateframeurl}}" scrolling="auto" frameborder="0" width="100%" height="250" id="updateframe"></iframe>
	</div>
	<br>
	<b><a href='{{baseurl}}update/'>&lt; back to app update menu</a></b>
{% endblock content %}
